import {http} from "@/service/http";
import {Role} from '@/types/user'
import {Page, PageQuery} from "@/types/response";


const prefix = '/Role'

/**
 * delete
 * @param id id
 * @returns
 */
export const removeRoleBydId = (id: number) => {
  return http({
    method: 'Delete',
    url: `${prefix}/Delete`,
    params: {
      id
    }
  })
}


/**
 * Page
 * @param page page 1
 */
export const getRolePage = (page: PageQuery) => {
  return http<Page<Role>>({
    method: 'GET',
    url: `${prefix}/Get`,
    params: {
      ...page
    }
  })
}


/**
 * getUserInfo
 * @param id userId
 * @returns UserInfo
 */
export const getRoleById = (id: number | string) => {
  return http<string>({
    method: 'Get',
    url: `/${prefix}/Get/${id}`,
  })
}


/**
 * 添加User
 * @param role User
 * @returns
 */
export const createRole = (role: Role) => {
  return http({
    method: 'POST',
    url: `/${prefix}/Post`,
    data: role
  })
}


/**
 * updateRole
 * @param role
 * @returns
 */
export const updateRole = (role: Role) => {
  return http({
    method: 'Put',
    url: `/${prefix}/Put`,
    data: role
  })
}

